//
//  IndexTwoItemSizeCell.m
//  YunFu
//
//  Created by Bager on 2018/8/31.
//  Copyright © 2018年 yunfu. All rights reserved.
//

#import "IndexTwoItemSizeCell.h"

@implementation IndexTwoItemSizeCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setViews];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setViews
{
    [self addSubview:self.img];
    [self addSubview:self.name];
}

- (UIImageView *)img
{
    if (!_img)
    {
        _img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, (kScreenWidth - kPublicMargin * 2) / 2.0, 80)];
        _img.contentMode = UIViewContentModeScaleAspectFill;
        _img.layer.masksToBounds = YES;
        CAGradientLayer *gradientLayer = [CAGradientLayer layer];
        gradientLayer.colors = @[(__bridge id)[UIColor clearColor].CGColor, (__bridge id)[UIColor colorWithWhite:0 alpha:0.5].CGColor];
        gradientLayer.locations = @[@0.3, @1.0];
        gradientLayer.startPoint = CGPointMake(0, 0);
        gradientLayer.endPoint = CGPointMake(0, 1.0);
        gradientLayer.frame = CGRectMake(0, 50, CGRectGetWidth(_img.frame), 30);
        [_img.layer addSublayer:gradientLayer];
    }
    return _img;
}

- (UILabel *)name
{
    if (!_name)
    {
        _name = [[UILabel alloc] initWithFrame:CGRectMake(0, 60, CGRectGetWidth(self.img.frame), 20)];
        _name.adjustsFontSizeToFitWidth = YES;
        _name.font = [UIFont systemFontOfSize:12];
        _name.textAlignment = NSTextAlignmentCenter;
        _name.textColor = [UIColor whiteColor];
    }
    return _name;
}


@end
